package com.school.gift.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.school.gift.domain.Evaluate;
import com.school.gift.mapper.EvaluateMapper;
import com.school.gift.model.EvaluateModel;
import com.school.gift.service.EvaluateService;
import zhibi.common.support.base.Page;
import zhibi.common.support.base.service.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import zhibi.common.support.mybatis.example.Example;

/**
 * The class create by 执笔 on generate.
 */
@Service
@Transactional
public class EvaluateServiceImpl extends BaseServiceImpl<Evaluate> implements EvaluateService {

    @Autowired
    public EvaluateServiceImpl(EvaluateMapper mapper) {
        super(mapper);
        this.evaluateMapper = mapper;
    }

    private EvaluateMapper evaluateMapper;

    @Override
    public PageInfo<EvaluateModel> selectByGoods(Integer goodsId, Page page) {
        if(null != page){
            PageHelper.startPage(page.getPageNum(),page.getPageSize());
        }
        return new PageInfo<>(evaluateMapper.selectByGoods(goodsId));
    }

    @Override
    public Evaluate selectByOrderId(Long id) {
        Evaluate evaluate = new Evaluate();
        evaluate.setOrderId(id);
        return evaluateMapper.selectOne(evaluate);
    }

    @Override
    public PageInfo<EvaluateModel> selectModel(Example example, Page page) {
        if(null != page){
            PageHelper.startPage(page.getPageNum(),page.getPageSize());
        }
        return new PageInfo<>(evaluateMapper.selectModel(example));
    }
}